# Use the latest 2.1 version of CircleCI pipeline process engine.
# See: https://circleci.com/docs/configuration-reference
version: 2.1

orbs:
  coveralls: coveralls/coveralls@2.2.1

# Define a job to be invoked later in a workflow.
# See: https://circleci.com/docs/configuration-reference/#jobs
jobs:
  code-coverage:
    # Specify the execution environment. You can specify an image from Docker Hub or use one of our convenience images from CircleCI's Developer Hub.
    # See: https://circleci.com/docs/configuration-reference/#executor-job
    docker:
      - image: hack2root/c-project:latest #cimg/base:edge-22.04
    # Add steps to the job
    # See: https://circleci.com/docs/configuration-reference/#steps
    steps:
      - checkout
      - setup_remote_docker:
          docker_layer_caching: true
      - run:
          name: "init"
          command: ./bin/init.sh --init --optional
      - run:
          name: "coverage"
          command: ./bin/coverageall.sh --all
      - store_artifacts:
          path: coverage
      - coveralls/upload:
          coverage_file: ./coverage/lcov.info

# Orchestrate jobs using workflows
# See: https://circleci.com/docs/configuration-reference/#workflows
workflows:
  coverage-workflow:
    jobs:
      - code-coverage
